package com.example.controller;

import com.example.entity.SkillGoods;
import com.example.service.SkillGoodsService;
import com.example.vo.Result;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Slf4j
public class SkillController {
    @Autowired
    private SkillGoodsService skillService;

    @Operation(summary = "秒杀商品")
    @PostMapping("/buyer/skill/{skillId}")
    public Result<String> skillGoods(@PathVariable Long skillId){
        return skillService.skillGoods(skillId);
    }

    @Operation(summary = "获取秒杀时间列表")
    @GetMapping("/buyer/common/skill/getSkillTimeList")
    public Result<List<Map<String,Object>>> getSkillTimeList(){
        List<Map<String,Object>> timeList = skillService.getSkillTimeList();
        return Result.ok(timeList);
    }

    @Operation(summary = "获取秒杀商品列表")
    @GetMapping("/buyer/common/skill/getSkillGoods")
    public Result<List<SkillGoods>> getSkillGoods(){
        List<SkillGoods> goodsList = skillService.getSkillGoods();
        return Result.ok(goodsList);
    }

}